package com.huangliusong.threadcurrency.example.future;

import lombok.extern.slf4j.Slf4j;

import java.util.concurrent.Callable;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.FutureTask;

/**
 * @author huangliusong
 * @since 2018/11/23
 * {@link }
 */
@Slf4j
public class FutureTaskExample {
    public static void main(String[] args) throws ExecutionException, InterruptedException {
        FutureTask<String> futureTask=new FutureTask<String>(new Callable<String>() {
            @Override
            public String call() throws Exception {
                System.out.println("执行call任务");
                return "执行完成" ;
            }
        });
        new Thread(futureTask).start();
        String s =futureTask.get();
        log.info("ok:"+s);
    }
}
